from config import OfflineTMSingle_path
from os.path import join

class OfflineTMSingle:
	def __init__(self, docId):
		self.path = join(OfflineTMSingle_path, str(docId))
	
	def load(self):
		self.model = {}
		f = open(self.path, 'r')
		line = f.readlines()[0]
		f.close()
		items = line.split()
		for item in items:
			self.model[int(item.split(':')[0])]=float(item.split(':')[1])
	def getProb(self, wordId):
		if self.model.has_key(wordId):
			return self.model[wordId]
		return 0.0
if __name__ == '__main__':
	otms = OfflineTMSingle(12)
	otms.load()
	print otms.getProb(262153)
